package node.java;

import com.google.common.base.Joiner;

/**
 * Created by thormentor on 27-04-2014.
 */
public class JavaField {
    private final String annotation;
    private final String type;
    private final String name;

    public JavaField(JavaClass javaClass, String type, String name, String annotation) {
        this.type = type;
        if ("0123456789".contains("" + name.charAt(0)))
            name = "_" + name;
        this.name = name;
        this.annotation = annotation;
        if (annotation != null)
            javaClass.addImport("entity.entity.entity_model.model.annotations.*");
    }

    @Override
    public String toString() {
        return Joiner.on("\n").skipNulls().join(
                annotation,
                String.format("\t%s %s;", type, name)
        );
    }
}
